import expect from 'expect.js'

import GeometryFactory from 'jsts/org/locationtech/jts/geom/GeometryFactory'
import PrecisionModel from 'jsts/org/locationtech/jts/geom/PrecisionModel'
import WKTReader from 'jsts/org/locationtech/jts/io/WKTReader'
import IsValidOp from 'jsts/org/locationtech/jts/operation/valid/IsValidOp'

describe('Test (#438)', function() {
  it('verify specific WKT parsing', function() {
    const wktGeometryA = 'POLYGON((1301712.757865992 6026164.346872674,1301669.7465115704 6026170.404811879,1301664.2943687106 6026171.616395722,1301615.83087192 6026176.765641262,1301605.8352784396 6026177.977221535,1301585.5411924808 6026180.40040435,1301582.332685697 6026182.526422543,1301589.7694125674 6026211.563888157,1301616.739922689 6026205.842624029,1301634.4706453828 6026207.233407627,1301673.0791028552 6026204.932816303,1301693.9789898398 6026203.721227319,1301743.9573375955 6026227.648949694,1301752.1362757408 6026214.016353954,1301726.3911354416 6026193.1131246565,1301712.757865992 6026164.346872674))'

    const factory = new GeometryFactory(new PrecisionModel(PrecisionModel.maximumPreciseValue))
    const reader = new WKTReader(factory)
    const featureAGeometry = reader.read(wktGeometryA)

    const isValidA = IsValidOp.isValid(featureAGeometry)
    expect(isValidA).to.be.ok()
  })
})
